<script type="text/javascript">
    function renameNote(id, oldName) {
        xnote.prompt("新名称", oldName, function (newName) {
            console.log(newName);
            if (newName != "" && newName != null) {
                $.post("/note/rename", {id:id, name:newName}, function (resp) {
                    var code = resp.code;
                    if (code != "success") {
                        alert(resp.message);
                    } else {
                        // $("#file-"+id).text(newName);
                        window.location.reload();
                    }
                })
            }
        });
    }

    function renameNoteByAttr(target) {
        var id = $(target).attr("data-id");
        var oldName = $(target).attr("data-name");
        renameNote(id, oldName);
    }

    window.rename = renameNote

    xnote.registerApiModule("note")
    xnote.api.note.rename = renameNote

</script>
